package test01;

class Solution {
    public void merge(int[] nums1, int m, int[] nums2, int n) {
        int p = 0, q = 0;
        int cur = 0;
        int[] sorted = new int[m + n];

        while (p < q) {
            if (nums1[p] >= nums2[q]) sorted[cur++] = nums1[p];
            else sorted[cur++] = nums2[q];
        }
        if (m + n >= 0) System.arraycopy(sorted, 0, nums1, 0, m + n);

    }
}